﻿using System;
using System.ComponentModel;
using XCI.Core;
using XCI.Helper;

namespace XCI.Windows
{
    public partial class BaseUserControl : DevExpress.XtraEditors.XtraUserControl
    {
        private LoadingMask _loading;
        private MutexStatus _mutex;
        private OnceAction _onceAction;

        public BaseUserControl()
        {
            InitializeComponent();
            if (WinFormHelper.IsDesignMode())  WinFormHelper.InitDesignFont();
        }

        protected override void OnLoad(EventArgs e)
        {
            if (WinFormHelper.IsDesignMode()) WinFormHelper.InitDesignFont();
            base.OnLoad(e);
        }

        /// <summary>
        /// 是否设计模式
        /// </summary>
        [Browsable(false)]
        protected new bool DesignMode => WinFormHelper.IsDesignMode();

        /// <summary>
        /// Loading面板
        /// </summary>
        [Browsable(false)]
        protected LoadingMask Loading => _loading ?? (_loading = new LoadingMask(this));

        /// <summary>
        /// 互斥状态
        /// </summary>
        [Browsable(false)]
        protected MutexStatus Mutex => _mutex ?? (_mutex = new MutexStatus());

        /// <summary>
        /// 一次性执行函数
        /// </summary>
        [Browsable(false)]
        protected OnceAction OnceAction => _onceAction ?? (_onceAction = new OnceAction());
    }
}
